package com.jadobo.xswing.attrib;

public enum HtmlElementTag {
	
	UNKNOWN_OR_UNHANDLED,
	h1,
	h2,
	h3,
	h4,
	h5,
	h6,
	label,
	input,
	div(label, input),
	p(div, label, input),
	td(input, label, p, div),
	tr(td),
	th(td),
	table(tr, th),
	form(div, label, input);
	
	HtmlElementTag[] allowedChild;
	
	HtmlElementTag(HtmlElementTag ... allowedChild) {
		this.allowedChild = allowedChild;
	}
	
	public boolean isComposite() {
		return allowedChild != null;
	}
	
	public HtmlElementTag[] getAllowedChild() {
		return allowedChild;
	}
	
	public boolean isAllowed(HtmlElementTag tag) {
		if(allowedChild == null) {
			return false;
		}
		
		for(HtmlElementTag allowed : allowedChild) {
			if(allowed.equals(tag)) {
				return true;
			}
		}
		
		return false;
	}

}
